package com.itjh.mapper;

import com.itjh.dto.EmpDto;
import com.itjh.dto.EmpLoginDto;
import com.itjh.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {

    /*
    // 没有使用分页插件之前的代码
    //查询总记录数
    @Select("select count(*) from emp")
    public Long getTotal();

    //分页查询，获取列表数据
    @Select("select * from emp limit #{start},#{pageSize}")
    public List<Emp> getByPage(@Param("start") Integer start, @Param("pageSize") Integer pageSize);*/


    //员工信息查询
//    @Select("select * from emp")
    public List<Emp> getByPage(EmpDto empDto);

    //批量删除员工信息
    int deleteByIds(List<Integer> ids);

    int insertEmp(Emp emp);

    //根据id查询回显
    @Select("select * from emp where id = #{id}")
    Emp findById(Integer id);

    int updateEmp(Emp emp);

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp getByUsernameAndPassword(EmpLoginDto empLoginDto);

    //根据部门id删除部门下所有员工
    @Delete("delete from emp where dept_id = #{deptId}")
    int deleteByDeptId(Integer deptId);
}
